﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: QueryUtility.cs
//
//  Description: Holds several methods that can be used in a LINQ query.
// 
//--------------------------------------------------------------------------


using System;
using System.Linq;

namespace Chili.Opf3.Linq
{
	/// <summary>
	/// This class holds several methods that can be used in a LINQ query.
	/// </summary>
	public static class QueryUtility
	{
		/// <summary>
		/// Gets the maximum of the given value.
		/// </summary>
		/// <param name="member">The member that's maximum is returned.</param>
		public static long Max(object member)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Gets the minimum of the given value.
		/// </summary>
		/// <param name="member">The member that's minimum is returned.</param>
		public static long Min(object member)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Gets the count of the given value.
		/// </summary>
		/// <param name="member">The member that's count is returned.</param>
		public static long Count(object member)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Allows to specify a field that is only found in the storage and not in the
		/// peristent objects.
		/// </summary>
		/// <param name="field">The name of the field.</param>
		/// <param name="entity">The name of the entity.</param>
		public static T Field<T>(string entity, string field)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Allows to specify a field that is only found in the storage and not in the
		/// persistent objects.
		/// </summary>
		/// <param name="field">The name of the field.</param>
		/// <param name="persistent">The type of the persistent.</param>
		public static T Field<T>(Type persistent, string field)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Checks if the member is between the given two dates.
		/// </summary>
		/// <param name="member">The member that is checked.</param>
		/// <param name="begin">The begin of the time span.</param>
		/// <param name="end">The end of the time span.</param>
		public static bool Between(DateTime member, DateTime begin, DateTime end)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Checks if the member is equals to one of the given items.
		/// </summary>
		/// <param name="member">The member who is checked for values.</param>
		/// <param name="items">The items the member is checked for.</param>
		public static bool In(object member, params object[] items)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}

		/// <summary>
		/// Checks if the time span specified with the first to arguments is overlapping with the time span specified
		/// in the third and fourth argument.
		/// </summary>
		/// <param name="begin1">The begin of the first time span that is checked for overlap.</param>
		/// <param name="end1">The end of the first time span that is checked for overlap.</param>
		/// <param name="begin2">The begin of the second time span that is checked for overlap.</param>
		/// <param name="end2">The end of the second time span that is checked for overlap.</param>
		public static bool Overlaps(DateTime begin1, DateTime end1, DateTime begin2, DateTime end2)
		{
			throw new NotSupportedException("Only allowed in LINQ queries.");
		}
	}
}

